<%@page import="com.infolab.aims.domain.workorder.WorkOrderTechnician"%>
<%@ include file="/WEB-INF/views/taglib.jsp" %>
<h3>Work Order Technician's Time Updation Form</h3>	
	<form:form id="form" method="post" modelAttribute="workOrderTechnician" cssClass="simpleForm">		
		<form:hidden path="workOrderTechnicianId" />
		<form:hidden path="workOrder.workOrderId" />
		<form:hidden path="workOrder.dateBooking" />
		<form:hidden path="technician.nric" />
		<form:hidden path="technician.personName" />
		<input name="success" id="success" type="hidden" value="${success}"/>
	 	<div class="clear" style="height:1px">&nbsp;</div>
		<jsp:include page="/WEB-INF/views/message.jsp"></jsp:include>
		
        <div class="content">
        	<div class="CD_contentStatus clearfix">
            	<span class="left">Work Order Code : <strong>
				${workOrderTechnician.workOrder.workOrderCode}</strong></span> 				            
        	</div>
        	
        	
        	
	  		
	  		<fieldset>
	  		<legend>Technician Info</legend>
	  		<div class="span-22">
	  		<p class="clearfix">
	  			<label>Name</label>
	  			${workOrderTechnician.technician.personName}
	  		</p>
	  		
	  		<p class="clearfix">
	  			<label>Work Order Date</label>
	  			<fmt:formatDate value="${workOrderTechnician.workOrder.dateBooking}" pattern="${globalDateFormatJava}"/>	
	  		</p>
	  		
	  		<c:choose>
	  		<c:when test="${success!='Y'}">					
			<aims:column cssErrorClass="error" path="startTm" >
		  		<form:label path="startTm" >
		  			Start Time 
		 		</form:label>
		  		<form:input path="startTm" value="hh:mm" maxlength="5"/>				  		
		  		<form:errors path="startTm"  cssClass="errorSimple" /> 
			</aims:column>
			
				<aims:column cssErrorClass="error" path="endTm" >
		  		<form:label path="endTm" >
		  			End Time 
		 		</form:label>
		  		<form:input path="endTm" value="hh:mm" maxlength="5"/>				  		
		  		<form:errors path="endTm"  cssClass="errorSimple" /> 
			</aims:column>
			</c:when>
			<c:otherwise>
			
			<p class="clearfix">
			<label>Start Time</label>
	  		<fmt:formatDate value="${workOrderTechnician.timeStart}" pattern="${globalDateTimeFormatJava}"/>	
	  		</p>
	  		
	  		<p class="clearfix">	
  			<label>End Time</label>
  			<fmt:formatDate value="${workOrderTechnician.timeEnd}" pattern="${globalDateTimeFormatJava}"/>
  			</p>	
			</c:otherwise>
	  		</c:choose>
	  		
	  		<c:if test="${success!='Y'}">		
	  		<p class="clearfix"> 
	  			<label>Update WO Time too?</label>  <input checked='checked' name="woTimeUpdate" type="checkbox" value="true"/>
			</p>
			</c:if>
				  				  			  		
	  		<hr />
	  		
	  		</div>
	  		
	  		</fieldset>
	  		</div>
	  		
	  <div class="action">
	  	<c:choose>
	  		<c:when test="${workOrderTechnician.workOrder.workOrderId!=null}">
  				<c:if test="${success!='Y'}">		  			
	  			<button type="button" class="button positive" onclick="formSubmit()">
	  			Save
	  			</button>
	  			</c:if>  				
	  		</c:when>
	  	</c:choose>
	 </div>	
	  	     
	</form:form>
	
	<script type="text/javascript">
	
	$(document).ready(function() {
		
		$(window).unload(function() {
			  window.opener.reloadParent();
		});		
		
	});
	
	
	function redirect(form,url){
		form.attr('action',url );		
		form.submit();
	}
	
	function formSubmit(){
		if(validateForm()){
		//var url = "<c:url value="/workOrder/editWorkOrderTime"/>";
		var form = $('#form');
		form.submit();
		//redirect(form,url);
		}
	}
	
	function validateForm(){
		return true;
	}
	
	
		
	</script>
	